<?php

/*
* @Author: 玛瑙
* @Date:   2018-04-24 13:22:44
* @Last Modified by:   Administrator
* @Last Modified time: 2018-05-08 09:52:47
*/
namespace app\company\controller;

class Template extends Common {
	/**
	 * 小型车
	 */
	public function car_small() {
		$map['company_id'] = session('company.company_id');
		$map['is_delete'] = 0;
		$map['license_type'] = 1;
		$data['list'] = db('inspection_item_model')
		->field('id,inspection_id,inspection_status')
		->where($map)
		->order('inspection_id')
		->select();
		return view('',$data);
	}

	/**
	 * 中型车
	 */
	public function car_middle() {
		$map['company_id'] = session('company.company_id');
		$map['is_delete'] = 0;
		$map['license_type'] = 2;
		$data['list'] = db('inspection_item_model')
		->field('id,inspection_id,inspection_status')
		->where($map)
		->order('inspection_id')
		->select();
		return view('car_small',$data);
	}

	/**
	 * 大型车
	 */
	public function car_big() {
		$map['company_id'] = session('company.company_id');
		$map['is_delete'] = 0;
		$map['license_type'] = 3;
		$data['list'] = db('inspection_item_model')
		->field('id,inspection_id,inspection_status')
		->where($map)
		->order('inspection_id')
		->select();
		return view('car_small',$data);
	}

	/**
	 * 挂车
	 */
	public function car_three() {
		$map['company_id'] = session('company.company_id');
		$map['is_delete'] = 0;
		$map['license_type'] = 4;
		$data['list'] = db('inspection_item_model')
		->field('id,inspection_id,inspection_status')
		->where($map)
		->order('inspection_id')
		->select();
		return view('car_small',$data);
	}

	/**
	 * 修改保存
	 */
	public function save() {
		$data = input('post.');
		foreach ($data as $key => $value) {
			$x = explode(',',$value);
			$map['id'] = $x[0];
			$map['inspection_id'] = $x[1];
			$map['inspection_status'] = $x[2];
			try {
				doModify('inspection_item_model',$map);
			} catch (Exception $e) {
				return json([
					'statusCode' => 300,
					'message' => $e->getMessage(),
					]);
			}
		}
		return json([
			'statusCode' => 200,
			'message' => '修改成功',
			]);
	}
}